package lab02.Test21;

/**
 * Created by 李晓容 on 2017/10/31.
 */
public class Test {

        public static void main(String[] args) {
            //21、 	统计一个字符串中给定字符出现的频率。

            String string = "asdfasdasa";
            char special = 'a';

            int number = 0;
            for (int i = 0; i< string.length(); i++){
                if (string.charAt(i) == special){
                    number++;
                }
            }

            System.out.println("在字符asdfasdasa中 a出现的频率为："+number);
        }
    }



